Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

396
Visualizações
webpack entry filename config used [ext] placeholders not take effect

I'm sorry for my English is low,hope you understand. I learning how to use webpack build my project.The following is config for two entry files:

 entry:{
    main: {
      import: "./src/main.js",
      filename:"main/[name].[hash:6][ext]",
      dependOn:"lodash"
    },
    index:{
      import:"./src/index.js",
      filename:"index/[name].[hash:6][ext]",
      dependOn:"lodash"
    },
    lodash: {import: [ "lodash" ],filename:"lodash/[name].[hash:6].js" }
  },

I think it will generator two files after I execute the npm run build script,for example,main.a24fc1.js and index.b42afd.js ,their name should look like that.

But in result they is this:

|- build
  |- index
    |- index.81c047[ext]
  |- main
    |- main.81c047[ext]

In their filename config,used [ext] placeholders but it's not take effect.I don't know why it happended,becouse my config the same as in webpack document's demo.

// This is webpack demo config:
module.exports = {
  //...
  entry: {
    app: './app.js',
    home: { import: './contact.js', filename: 'pages/[name][ext]' },
    about: { import: './about.js', filename: 'pages/[name][ext]' },
  },
};

I are unable solve the problem...Thank to everyone helped me!(Please tell me if there are has any English mistakes in this article.^_^)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have specified the output to be main/[name].[hash:6][ext] hence the folder structure. Just specify it as [name].[hash:6].js and you will get your desired structure.

entry:{
    main: {
      import: "./src/main.js",
      filename:"[name].[hash:6].js",
      dependOn:"lodash"
    },
    index:{
      import:"./src/index.js",
      filename:"[name].[hash:6].js",
      dependOn:"lodash"
    },
    lodash: {import: [ "lodash" ],filename:"[name].[hash:6].js" }
},

Note that the filename property in the entry block is extracted from output.filename(Source) which does not support [ext]. (Source - Table - Substitutions available on File-level)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda